package com.top4create.face;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import com.top4create.R;
import com.top4create.Main;
import com.top4create.component.MenuUtil;

public abstract class BasicActivity extends Activity {
    /**
     * Called when the activity is first created.
     */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
//        setContentView(R.layout.main);
//        setContentView(R.attr.class);
    }

    static final public int HOME = Menu.FIRST;
    static final public int SEARCH = Menu.FIRST + 1;
    static final public int FAVORITE = Menu.FIRST + 2;
    static final public int MANAGEMENT = Menu.FIRST + 3;


    Intent intent;

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        super.onCreateOptionsMenu(menu);
        return MenuUtil.createMenu(menu);
    }

    //菜单项选择事件
    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        Intent intent;

        switch (item.getItemId()) {
            case HOME:
                intent = MenuUtil.createIntent4Menu(this, Main.class);
                startActivityForResult(intent, 1);
                break;
            case SEARCH:
                intent = MenuUtil.createIntent4Menu(this, Search.class);
                startActivityForResult(intent, 1);
                break;
            case FAVORITE:
                intent = MenuUtil.createIntent4Menu(this, ConpanyInfo.class);
                startActivityForResult(intent, 1);
                break;
            case MANAGEMENT:
                intent = MenuUtil.createIntent4Menu(this, Login.class);
                startActivityForResult(intent, 1);
                break;
        }
        return false;
    }

    private String request = "";

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (resultCode == Activity.RESULT_OK && requestCode == 0) {
            if (data != null) {
                request = data.getStringExtra("request");
//                data.get
            }
        }
    }
}
